﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using HigLabo.Net.Extensions;

namespace HigLabo.Net.Dropbox
{
    public class DropboxResponseException: HttpResponseException
    {
        public String ErrorMessage { get; set; }
        public DropboxResponseException(HttpResponse response)
            : base(response)
        {
            this.SetProperty();
        }
        private void SetProperty()
        {
            try
            {
                var d = JsonConvert.DeserializeObject<Dictionary<String, Object>>(this.BodyText);
                this.ErrorMessage = d.ToString("error");
            }
            catch { }
        }
    }
}
